home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
include
/
voronoi.h
< prev
Wrap
C/C++ Source or Header
|
1994-08-01
|
3KB
|
139 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
#define MAXSITES 4096
/* GL DRAWING STUFF */
/* vertex: x, y */
struct vertstruct {
float x, y;
int vpid;
};
/* vertex id w/neighbors */
struct nvertstruct {
int nbr1, nbr2, onhull;
int vpid;
};
/* vertex: x, y, theta */
struct vertthetastruct {
float x, y, theta;
int e1, e2;
};
/* edge: CLIPPED to reasonable bounds */
struct edgestruct {
float x1, y1, x2, y2;
int nbr1, nbr2;
float xm, ym; /* halfway between inducing voronoi sites */
};
typedef struct vertstruct VERT;
typedef struct nvertstruct NVERT;
typedef struct vertthetastruct VERTTHETA;
typedef struct edgestruct EDGE;
/* triangle: holds POINTERS to three verts */
struct tristruct {
VERT *v1, *v2, *v3;
};
struct circstruct {
float cx, cy, r;
int nbr1, nbr2, nbr3;
};
typedef struct tristruct TRI;
typedef struct circstruct CIRC;
#define MAXVERTS (3 * MAXSITES)
#define MAXEDGES (2 * MAXSITES)
#define MAXTRIS (MAXEDGES)
extern VERT GLsites[MAXVERTS];
extern VERT verts[MAXVERTS];
extern EDGE vedges[MAXEDGES];
extern NVERT chverts[MAXVERTS];
extern TRI tris[MAXTRIS];
extern CIRC circles[MAXTRIS];
/* load_vsites():
accept the n voronoi sites (x_n, y_n)
calculate and store the voronoi diagram over the n sites,
clipping all infinite edges to bbox: [xmin, ymin, xmax, ymax].
note: if (xmin,ymin,xmax,ymax are all == 0.0), OR
if these do not enclose the data, a bounding box
will be computed over the input.
returns:
-1 if error
0 otherwise
*/
int
load_vsites (
int n,
float usites[][2], /* sites in x,y order */
float uxmin, float uymin, float uxmax, float uymax);
/*
find_vregion(sid, plen, pverts)
given a site id 'sid' from 0..nsites-1 inclusive,
returns the voronoi polygon associated with that site
in the array 'pverts', and its length on call stack.
the vertices are returned in counterclockwise order.
returns:
-1 if error condition
plen > 2 [i.e., the # of verts in the voronoi polygon] otherwise
*/
int
find_vregion (
int vsid,
float pverts[][2]);
/*
int
find_dtriangles (**dtris)
returns:
-1 if error condition, *dtris == NULL
o/wise, # of delaunay triangles, *dtris == array of TRIS (see voronoi.h)
*/
int
find_dtriangles (
TRI **dtris);
/*
int
find_convexhull (**chverts)
returns:
if error condition
*chverts == NULL
returns -1
o/wise,
*chverts == array of named VERTs (see voronoi.h), in order around convex hull
*chvert[k].vpid == index of point in point set given to load_vertices()
returns # of convex hull vertices
*/
int
find_convexhull(
NVERT **chvertices);